package com.handler.utils;

import io.netty.buffer.ByteBuf;

import java.io.FileInputStream;
import java.io.IOException;

public class FileReader {

    public static void read(String filePath, ByteBuf out, long continueTransportOffset){

        byte[] cache = new byte[1024];


        try (FileInputStream inputStream = new FileInputStream(filePath)) {

            inputStream.skip(continueTransportOffset);

            int readLength = 0;
            while ((readLength = inputStream.read(cache)) != -1) {
                out.writeBytes(cache, 0, readLength);
            }
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }

}
